package com.phapli.versionchecking.http;

import android.util.Log;

import com.phapli.versionchecking.config.Config;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

/**
 * Created by phapli on 3/7/2015.
 */
public class GooglePlayParser extends VersionParser {

    public GooglePlayParser(){
        super();
    }

    @Override
    public String parseVersionFromWeb(String url) {
        try {
            Document html = Jsoup.connect(url).get();
            Elements softwareVersion = html.select("div[itemprop=softwareVersion]");
            for(Element e: softwareVersion){
                return e.text();
            }
        } catch (IOException e) {
            Log.e(Config.LOG, e.getMessage());
        }

        return "";
    }
}
